#include <stdlib.h>
#include <math.h>
#include <stdio.h>
// X is the array
// numElement is the number of elements to be scanned
// offset is the starting index of the first elemetn in the sequence
// stride is the distance between the elements.
void seqScan(double *X, unsigned int numEl, unsigned int offset, 
		unsigned int stride)
{
	unsigned int i, j, index;
	unsigned int end = offset + numEl * stride;
		//printf("end = %d\n", end);
	for (i = offset + stride; i < end; i += stride)	 {
		//printf("i = %d\n", i);
		for (j = 0; j < stride; j++) {
			X[i + j] += X[(i - stride) + j]; 

		}
	}
}
// this does not work for dim > 1
void seqAdd(double *X, double val, unsigned int numEl, unsigned int offset, unsigned int stride) {
	unsigned int i;
	unsigned int end = offset - 1 + numEl * stride;
	for (i = offset - 1 + stride; i <= end; i += stride)	
		X[i] += val; 
}
